#ifdef __cplusplus
    #include <cstdlib>
#else
    #include <stdlib.h>
#endif

#include <SDL/SDL.h>

void affichageFenetre();
int choixType();
 void deplacer();
 void jouer();
 void quitter();

int main ( int argc, char** argv )
{
    int done=1,x,y;
    SDL_Event event;
    SDL_Event event1;
    SDL_Surface *fenetre1;
    freopen("CON","w",stdout);
    freopen("CON","r",stdin);




 if ( SDL_Init( SDL_INIT_VIDEO ) < 0 )

    {
        printf( "Unable to init SDL: %s\n", SDL_GetError() );
        return 1;
    }

    SDL_Surface* screen = SDL_SetVideoMode(640, 480, 16,
                                           SDL_HWSURFACE|SDL_DOUBLEBUF);
    SDL_Surface* bmp = SDL_LoadBMP("acc.bmp");

    SDL_Rect dstrect;
    dstrect.x = (screen->w - bmp->w) / 2;
    dstrect.y = (screen->h - bmp->h) / 2;


    SDL_FillRect(screen, 0, SDL_MapRGB(screen->format, 0, 0, 0));


    SDL_BlitSurface(bmp, 0, screen, &dstrect);


    SDL_Flip(screen);
         while(done)
         {
             while(SDL_PollEvent(&event))
                {
                 switch(event.type)
                  {case SDL_MOUSEBUTTONDOWN:
                   {int x=event.motion.x;
                   int y=event.motion.y;
                   printf("x=%d",x);
                   printf("Y=%d",y);
                   if(x<640 && x>323 && y<136 && y>40)
                     {
                      SDL_Surface* fenetre1 = SDL_SetVideoMode(640, 480, 16,
                                           SDL_HWSURFACE|SDL_DOUBLEBUF);
    SDL_Surface* bmp = SDL_LoadBMP("h1.bmp");

    SDL_Rect dstrect;
    dstrect.x = (screen->w - bmp->w) / 2;
    dstrect.y = (screen->h - bmp->h) / 2;

    SDL_FillRect(screen, 0, SDL_MapRGB(screen->format, 0, 0, 0));


    SDL_BlitSurface(bmp, 0, screen, &dstrect);


    SDL_Flip(screen);

                }
                     if(x<640 && x>281 && y<229 && y>136)
                    {
                      SDL_Surface* fenetre1 = SDL_SetVideoMode(640, 480, 16,
                                           SDL_HWSURFACE|SDL_DOUBLEBUF);
    SDL_Surface* bmp = SDL_LoadBMP("ac1.bmp");

    SDL_Rect dstrect;
    dstrect.x = (screen->w - bmp->w) / 2;
    dstrect.y = (screen->h - bmp->h) / 2;

    SDL_FillRect(screen, 0, SDL_MapRGB(screen->format, 0, 0, 0));


    SDL_BlitSurface(bmp, 0, screen, &dstrect);


    SDL_Flip(screen);

                     }

                     if(x<640 && x>290 && y<347 && y>229)
                    printf("option");
                     if(x<640 && x>271 && y<459 && y>347)
                    done=0;}
                    break;

                    case SDL_QUIT:
                    done = 0;
                    break;

                case SDL_KEYDOWN:


                    if (event.key.keysym.sym == SDLK_ESCAPE)
                        done = 0;

               break;



                  }
                }

         }
         SDL_FillRect(screen, 0, SDL_MapRGB(screen->format,255,255,0));


         SDL_BlitSurface(bmp, 0, screen, &dstrect);


         SDL_Flip(screen);
    return 0;
}
